/**
 * Created by JustinChow on 2016/11/7.
 */

// This Class Base On "碰撞盒表.xlsx" From Design Document.

const Vector = require("../Utils/Vector");

const BOX_TYPE_CIRCLE = 0;
const BOX_TYPE_RECTANGLE = 1;

const COLLISION_PASS = 1;
const COLLISION_STOP = -1;

function Collision() {
    // 0 is circle, 1 is rectangle
    this.boxType     = BOX_TYPE_CIRCLE;
    // an unsigned float when box type is 0, an array of unsigned float when box type is 1
    this.boxSize     = new Vector();
    // if props can across, -1 means not, 1 means yes
    this.through     = COLLISION_PASS;
}

module.exports = Collision;

Collision.BOX_TYPE_CIRCLE    = BOX_TYPE_CIRCLE;
Collision.BOX_TYPE_RECTANGLE = BOX_TYPE_RECTANGLE;

Collision.COLLISION_PASS     = COLLISION_PASS;
Collision.COLLISION_STOP     = COLLISION_STOP;

Collision.prototype.init = function (boxType, box, through) {
    // if (boxType instanceof Collision) {
    //     // Passed In Collision Object
    //     this.through     = boxType.through;
    //     this.boxSize     = boxType.boxSize;
    //     this.boxType     = boxType.boxType;
    //
    // } else if (arguments.length === 1){
    //     // Load Collision Data Via collisionId
    //     this.through     = this.staticConfig.through;
    //     this.boxSize     = new Vector(this.staticConfig.boxSize[0], this.staticConfig.boxSize[1]);
    //     this.boxType     = this.staticConfig.boxType;
    //
    // } else if (arguments.length !== 3) {
    //     // Init Default Data
    //     this.through     = COLLISION_PASS;
    //     this.boxSize     = new Vector();
    //     this.boxType     = BOX_TYPE_CIRCLE;
    //
    // } else {
        // Init With 3 Arguments
        if (typeof box == "number") box = [box, box];
        else if (Array.isArray(box) && box.length == 1) box = [box[0], box[0]];

        this.through     = through;
        this.boxSize     = new Vector(box[0], box[1]);
        this.boxType     = boxType;
    // }
};

Collision.prototype.loadConfig = function () {

};